<template>
  <div class="cataAdd">
		<!-- 表单验证 -->
    <h1>lalal</h1>
     <el-form ref="cateAdd" :rules="rules" :model="cate" label-width="80px">
      <el-form-item label="分类名称" prop="cateName">
        <el-input v-model="cate.cateName"></el-input>
      </el-form-item>
      <el-form-item label="父级">
        <el-select v-model="cate.pid" placeholder="请选择父级分类">
          <el-option
            v-for="cate in cates"
            :key="cate.id"
            :label="cate.cateName"
            :value="cate.id"
          ></el-option>
          <el-option label="顶层分类" :value="0"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="分类图标">
        <el-upload
          class="upload-demo"
          name="file"
          action="/api/upload"
          :on-success="uploadSuccess"
          :on-error="uploadFail"
          :before-upload="beforeUpload"
        >
          <el-button size="small" type="primary">点击上传</el-button>
          <div slot="tip" class="el-upload__tip">
            只能上传jpg/png文件，且不超过500kb
          </div>
        </el-upload>
        <img :src="cate.icon" width="100" alt="">
      </el-form-item>
      <el-form-item label="是否启用">
        <el-switch
          :active-value="1"
          :inactive-value="0"
          v-model="cate.usable"
        ></el-switch>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="onSubmit">立即创建</el-button>
        <el-button>取消</el-button>
      </el-form-item>
    </el-form>
    <!-- /表单验证 -->
  </div>
</template>

<script>
export default {
  name: 'cataAdd'
}
</script>

<style lang="scss" scoped>

</style>
